const express = require('express');

const adminModel = require('../db/model/admin')

route = express.Router()
route.delete('/deleteadmin', async (req, res) => {
    const { adminName } = req.query;
    console.log(adminName);
    try {
        const findResult = await adminModel.deleteOne({ adminName })

        if(findResult.deletedCount > 0){
            return res.send({
                code:10000,
                msg:'删除管理员'+adminName+'的信息成功',
                data:null
            })
        }
        res.send({
            code:10003,
            msg:'删除管理员'+adminName+'信息失败',
            data:null
        })
    } catch (e) {
        console.log('删除管理员信息异常'+e.message);
        res.send({
            code:10003,
            msg:'删除管理员信息异常',
            data:null
        })
    }

})

module.exports = route;